package chinese.admin.controllers;

import java.util.List;

import net.paoding.rose.web.annotation.Path;
import net.paoding.rose.web.annotation.Param;
import net.paoding.rose.web.annotation.rest.Get;
import net.paoding.rose.web.annotation.rest.Post;
import net.paoding.rose.web.var.Model;
import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;

import chinese.admin.dao.ChnArticlePVDAO;
import chinese.admin.domain.ChnArticlePV;

/**
 * <p>实体类</p>
 * <p>Table: ChnArticlePV</p>
 *
 */
@Path("chnarticlepv")
public class ChnArticlePVController {
	@Autowired
	private ChnArticlePVDAO chnarticlepvDao;
	
	@Get("show")
	public String show(Model model){
		return "chnarticlepvShow.vm";
	}
	
	@Post("list")
	public String list(ChnArticlePV chnarticlepv){
		JSONObject jo = new JSONObject();
		
		List<ChnArticlePV> objs = chnarticlepvDao.query(chnarticlepv);
		jo.put("objs", objs);
		return "@" + jo.toString();
	}
	
	@Get("invent")
	public String invent(Model model){
		return "chnarticlepvDetail.vm";
	}
	
	@Post("create")
	public String create(ChnArticlePV chnarticlepv){
		JSONObject jo = new JSONObject();
		
		chnarticlepvDao.create(chnarticlepv);
		return "@" + jo.toString();
	}
	
	@Get("edit")
	public String edit(Model model){
		return "chnarticlepvEdit.vm";
	}
	
	@Post("update")
	public String update(ChnArticlePV chnarticlepv){
		JSONObject jo = new JSONObject();
		
		chnarticlepvDao.update(chnarticlepv);
		return "@" + jo.toString();
	}
	
	@Get("delete")
	public String delete(@Param("id")int id){
		JSONObject jo = new JSONObject();
	
		chnarticlepvDao.delete(id);
		return "@" + jo.toString();
	}

}